package com.zjdiepu.www.commpent.mapper.yw;

import javax.annotation.Resource;

import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.stereotype.Component;

import com.zjdiepu.www.base.core.BaseMapper;
import com.zjdiepu.www.base.enums.type.DataDicType;
import com.zjdiepu.www.commpent.RedisObjectClient;
import com.zjdiepu.www.ibiz.third.IJuheCityService;
import com.zjdiepu.www.ibiz.third.IJuheProvinceService;
import com.zjdiepu.www.model.base.dto.SimpleDataDictionary;
import com.zjdiepu.www.model.yw.dto.YwBusinessCar;

/**
 * 项目名称：dpqc-parent-manager-information <br/> 
 * 类名称：YwBusinessCarVoMapper <br/>  
 * 类描述： 车辆信息 <br/>    
 * 创建人：xiongxiaotun <br/> 
 * 创建时间：2017年4月26日 下午5:29:32  <br/>   
 * 修改人：xiongxiaotun <br/> 
 * 修改时间：2017年4月26日 下午5:29:32   <br/>  
 * 修改备注：    <br/> 
 * @version V1.0   <br/>
 */
@Component
public class YwBusinessCarVoMapper extends BaseMapper<YwBusinessCar>{
	@Resource
	private IJuheProvinceService juheProvinceService;
	@Resource
	private IJuheCityService juheCityService;
	@Resource
	private RedisObjectClient redisObjectClient;
	
	@Override
	public void mapper(RedisConnection redisConnection,YwBusinessCar m) {
		if(null == m) {
			return;
		}
		String carType = m.getCarType();
		SimpleDataDictionary simpleDataDictionary1 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(),carType, DataDicType.CAR_TYPE.getCode());
		m.setCarTypeDisplay(simpleDataDictionary1 == null ? "" : simpleDataDictionary1.getName());
		
		String carPlace = m.getCarPlace();
		SimpleDataDictionary simpleDataDictionary2 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(),carPlace, DataDicType.CAR_PLACE.getCode());
		m.setCarPlaceDisplay(simpleDataDictionary2 == null ? "" : simpleDataDictionary2.getName());
		
		String licencePlateType = m.getLicencePlateType();
		SimpleDataDictionary simpleDataDictionary3 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(),licencePlateType, DataDicType.LICENCE_PLATE_TYPE.getCode());
		m.setLicencePlateTypeDisplay(simpleDataDictionary3 == null ? "" : simpleDataDictionary3.getName());
		
		String carStatus = m.getCarStatus();
		SimpleDataDictionary simpleDataDictionary4 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(),carStatus, DataDicType.CAR_STATUS.getCode());
		m.setCarStatusDisplay(simpleDataDictionary4 == null ? "" : simpleDataDictionary4.getName());
		
		String carPurpose = m.getCarPurpose();
		SimpleDataDictionary simpleDataDictionary5 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(),carPurpose, DataDicType.CAR_PURPOSE.getCode());
		m.setCarPurposeDisplay(simpleDataDictionary5 == null ? "" : simpleDataDictionary5.getName());
		
		String categoryCar = m.getCategoryCar();
		SimpleDataDictionary simpleDataDictionary6 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(),categoryCar, DataDicType.CAR_CATEGORY.getCode());
		m.setCategoryCarDisplay(simpleDataDictionary6 == null ? "" : simpleDataDictionary6.getName());
		
		String colorCar = m.getColorCar();
		SimpleDataDictionary simpleDataDictionary7 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(),colorCar, DataDicType.CAR_COLOR.getCode());
		m.setColorCarDisplay(simpleDataDictionary7 == null ? "" : simpleDataDictionary7.getName());
		
		String evaluateProvince = m.getEvaluateProvince();
		m.setEvaluateProvinceDisplay(juheProvinceService.getNameById(evaluateProvince));
		String evaluateCity = m.getEvaluateCity();
		m.setEvaluateCityDisplay(juheCityService.getNameById(evaluateCity));
	}

}
